package com.xl.baseMethod;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static java.lang.Thread.sleep;

/**
 * JdkVersion: 1.8
 * Author: lei·xie
 * Created: 2024/8/5 0002 10:22
 * Description: 基本方法 interrupt打断正常线程
 */
@Slf4j(topic = "b.Test11")
public class ThreadDemo11 {
    public static void main(String[] args) throws InterruptedException{
        test1();
    }

    private static void test1() throws InterruptedException {
        Thread t1 = new Thread(() -> {
            log.debug("park..");
            LockSupport.park();
            log.debug("unpark...");
            log.debug("打断状态：{}", Thread.interrupted());
            LockSupport.park();
            log.debug("unpark...");
        },"t1");
        t1.start();
        sleep(1000);
        t1.interrupt();
    }
}
